﻿using System;
using System.Collections.Generic;
using tour.szhome.common;
using TOUR.SZHOME.DAL;
using TOUR.SZHOME.Entity;
namespace TOUR.SZHOME.BLL
{
    /// <summary>
    /// 数据表Adv的业务逻辑类
    /// </summary>
    public class AdvBLL
    {
        /// <summary>
        /// 获取列表 -- 分页
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="pageSet"></param>
        /// <returns></returns>
        public List<AdvEntity> GetList(PageSet pageSet)
        {
            string where = " 1 = 1 ";
            pageSet.RecordCount = AdvDAL.SearchCount(where);
            pageSet.PageCount = (int)Math.Ceiling(pageSet.RecordCount / (pageSet.PageSize * 1.0));
            return AdvDAL.Search(where, "AdvID", (pageSet.PageIndex - 1) * pageSet.PageSize, pageSet.PageSize);
        }

        /// <summary>
        /// 根据ID获取对象实体
        /// </summary>
        /// <param name="lid"></param>
        /// <returns></returns>
        public AdvEntity GetByID(int lid)
        {
            return AdvDAL.GetByAdvID(lid);
        }

        /// <summary>
        /// 根据ID删除对象
        /// </summary>
        /// <param name="nid"></param>
        /// <returns></returns>
        public bool DelByID(int nid)
        {
            return AdvDAL.Delete(nid);
        }

        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Edit(AdvEntity model)
        {
            if (model.AdvID > 0)
            {
                return AdvDAL.Update(model);
            }
            else
            {
                return AdvDAL.Insert(model);
            }
        }
    }
}
